<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit">
    <title></title>
    <include file="block:easyui_header" />
</head>
<body>
    <div class="easyui-panel" title="{$role[name]}-<?php echo LANG('role_priv_panel_title')?>" style="width:300px;height:450px;">
        <ul id="tt" class="easyui-tree" data-options="url:'__URL__/get_menu_priv_json?role_id={$role['id']}',animate:true,checkbox:true,lines:true">
        </ul>

    </div>
    <button onclick="save_role_priv()">确定</button>
</body>
<script type="text/javascript">
    function save_role_priv(){
        var url = '__URL__/save_role_priv';
        var role_id = {$role['id']};
        var ids = getChecked();
        var data = {'role_id':role_id, 'data': ids};
        $.post(url, data, function(result){
//            alert('修改成功');
            console.log(result);
            window.location.href = window.location.href;
        });
    }
    /**
     * 获取选中的值
     * @returns {string}
     */
    function getChecked(){
        var nodes = $('#tt').tree('getChecked');
        var s = '';
        for(var i=0; i<nodes.length; i++){
            if (s != '') s += ',';
            s += nodes[i].id;
        }
        return s;
    }
</script>
</html>